package org.bing.engine.common.remoting.hessian;

import org.bing.engine.common.remoting.RemotingFactoryBean;
import org.bing.engine.utility.helper.StringHelper;


public class SpringHessianFactoryBean extends RemotingFactoryBean {

    private String serviceId;

    public void setServiceId(String id) {
        this.serviceId = id;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void afterPropertiesSet() {
        String sid = "";
        if (StringHelper.isBlank(serviceId)) {
            sid = "$";
        } else {
            sid = serviceId + "$";
        }
        String url = serviceUrl.endsWith("/") ? serviceUrl + sid : serviceUrl + "/" + sid;
        serviceProxy = proxyFactory.create(serviceInterface, url);
    }

    public Object getObject() throws Exception {
        return serviceProxy;
    }
}
